import * as types from "./mutations_types";
import { setStore } from "@/config/utils";
import { util } from "../config/utils";
export default {
  // 设置页面切换loading
  [types.SET_LOADING_STATUS](state, status) {
    state.isLoading = status;
  },
  // 当前的搜索条件
  [types.SET_CUR_TERM](state, data) {
    state.params = data;
    setStore("params", state.params);
  },
  // 设置页面header
  [types.SET_HEADER_TITLE](state, router) {
    // 判断是否是收藏页面定制
    if (!router.isCollect) {
      state.fullPath = router.fullPath; // 当前页面
      if (router.matched.length > 1) {
        state.headerNavTitle =
          router.matched[2].meta.title == "首页"
            ? ""
            : router.matched[2].meta.title; // 一级路由
        state.headerSubTitle =
          router.matched.length == 4
            ? router.meta.title == state.headerNavTitle
              ? ""
              : router.meta.title
            : ""; // 二级路由
      }
    } else {
      state.fullPath = ""; // 当前页面
      state.headerNavTitle = router.headerNavTitle; // 一级路由
      state.headerSubTitle = router.name; // 二级路由
    }
    setStore("headerNavTitle", state.headerNavTitle);
    setStore("headerSubTitle", state.headerSubTitle);
  },
  // 保存当前首页通知进入详情页
  [types.SET_NOTICE_ID](state, noticeId) {
    state.noticeId = noticeId;
    setStore("noticeId", state.noticeId);
  }
};
